<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="同城帮买" name="first">

				<el-table v-loading="tableDataLoading" :data="homeData">
					<el-table-column fixed prop="id" label="编号" width="80">
					</el-table-column>
					<el-table-column prop = "ordersNo" label = "发布人昵称" width = "180"></el-table-column>
					<el-table-column prop = "ordersNo" label = "发布人头像" width = "180"></el-table-column>
					<el-table-column prop="title" label="物品名称">
					</el-table-column>
					<el-table-column prop="url" label="收货地址">
						<template slot-scope="scope">
							<span v-if="scope.row.status==1">详情</span>
							<span v-if="scope.row.status==2">列表</span>
						</template>
					</el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人昵称" width = "180"></el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人头像" width = "180"></el-table-column>
					<el-table-column prop="title" label="购买时间">
					</el-table-column>
					<el-table-column prop="title" label="预估商品费用">
					</el-table-column>
					<el-table-column prop="title" label="红包">
					</el-table-column>
					<el-table-column prop="title" label="小费">
					</el-table-column>
					<el-table-column prop="title" label="收货码">
					</el-table-column>
					<el-table-column prop="title" label="备注">
					</el-table-column>
					<el-table-column prop="title" label="跑腿费">
					</el-table-column>

					<!-- <el-table-column prop="content" label="图片">
						<template slot-scope="scope">
							<img :src="scope.row.imageUrl" alt="" width="40" height="40">
						</template>
					</el-table-column> -->
					<el-table-column prop="createAt" label="创建时间" width="160">
					</el-table-column>
					<el-table-column prop="state" label="是否启用">
						<template slot-scope="scope">
							<el-switch v-model="scope.row.state" @change="change2(scope.row.state,scope.row)"
								:active-value="openValue" :inactive-value="closeValue" active-color="#13ce66"
								inactive-color="#ff4949">
							</el-switch>
						</template>
					</el-table-column>
					<el-table-column label="操作" width="150">
						<template slot-scope="scope">
							<el-button size="mini" type="primary" :disabled="!isAuth('mission:update')"
								@click="compile(scope.$index, scope.row)">编辑
							</el-button>
							<el-button size="mini" type="danger" :disabled="!isAuth('mission:delete')"
								@click="navdeletes(scope.row)">删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<!-- <div style = "text-align: center;margin-top: 10px;">
			  <el-pagination @size-change = "handleSizeChange1" @current-change = "handleCurrentChange1" :page-sizes = "[10, 20, 30, 40]"
							 :page-size = "size" :current-page = "page" layout = "total,sizes, prev, pager, next,jumper"
							 :total = "homeData.length">
			  </el-pagination>
			div> -->
			</el-tab-pane>
			<el-tab-pane label="同城服务" name="second">

				<el-table v-loading="tableDataLoading" :data="bannerData" height="450px">
					<el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
					<el-table-column prop="imageUrl" label="服务类型">
						<template slot-scope="scope">
							　　<img :src="scope.row.imageUrl" width="60" height="60" />
						</template>
					</el-table-column>
					<el-table-column prop = "ordersNo" label = "发布人昵称" width = "180"></el-table-column>
					<el-table-column prop = "ordersNo" label = "发布人头像" width = "180"></el-table-column>
					<el-table-column prop="name" label="文字描述"></el-table-column>
					<el-table-column prop="name" label="服务地址"></el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人昵称" width = "180"></el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人头像" width = "180"></el-table-column>
					<el-table-column prop="name" label="上门时间"></el-table-column>
					<el-table-column prop="name" label="红包"></el-table-column>
					<el-table-column prop="name" label="小费"></el-table-column>
					<!-- <el-table-column prop="name" label="是否自备配件"></el-table-column> -->
					<el-table-column prop="name" label="保修期"></el-table-column>
					<el-table-column prop="name" label="服务费"></el-table-column>
					<!-- <el-table-column prop="state" label="状态">
						<template slot-scope="scope">
							<span v-if="scope.row.state == 1">显示</span>
							<span v-if="scope.row.state == 2" style="color: #f56c6c;">隐藏</span>
						</template>
					</el-table-column>
					<el-table-column prop="state" label="是否启用">
						<template slot-scope="scope">
							<el-switch v-model="scope.row.state" @change="change(scope.row.state,scope.row)"
								:active-value="openValue" :inactive-value="closeValue" active-color="#13ce66"
								inactive-color="#ff4949">
							</el-switch>
						</template>
					</el-table-column> -->
					<el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
					<el-table-column label="操作" width="180">
						<template slot-scope="scope">
							<el-button size="mini" type="primary" :disabled="!isAuth('bannerList:update')"
								@click="amendBanner(scope.$index, scope.row)">修改
							</el-button>
							<el-button size="mini" type="danger" :disabled="!isAuth('bannerList:delete')"
								@click="deletes(scope.row)">删除</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;float:right">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:page-sizes="[5, 10, 15, 20]" :page-size="limit" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="bannerData.length">
					</el-pagination>
				</div>

			</el-tab-pane>
			<el-tab-pane label="送取任务" name="third">
				<div style="display: inline-block;">
					<span>物品类型：</span>
					<el-select v-model="campus1" style="width:150px;margin-left: 10px;" @change="animeDat2(campus1)">
						<el-option v-for="item in homeData2" :key="item.campusId" :label="item.campusName"
							:value="item.campusId">
						</el-option>
					</el-select>&nbsp;&nbsp;&nbsp;
					<span>任务类型：</span>
					<el-select v-model="classifyIds" style="width:150px;margin-left: 10px;" @change="animeDat2(status)">
						<el-option v-for="item in homeData1" :key="item.value" :label="item.title" :value="item.id">
						</el-option>
					</el-select>&nbsp;&nbsp;&nbsp;
					<span>状态：</span>
					<el-select v-model="statusId" style="width:150px;margin-left: 10px;" @change="animeDat3(status)">
						<el-option v-for="item in statuss" :key="item.value" :label="item.title" :value="item.id">
						</el-option>
					</el-select>&nbsp;&nbsp;&nbsp;
					<div style="position: relative;display: inline-block;">
						<span>用户手机号:</span>
						<el-input style="width: 200px;" @keydown.enter.native="phoneSelect" placeholder="请输入手机号"
							v-model="myPhone">
						</el-input>&nbsp;&nbsp;
					</div>
					<div style="position: relative;display: inline-block;">
						<span>标题名称：</span>
						<el-input style="width: 200px;" @keydown.enter.native="phoneSelect" placeholder="请输入标题名称"
							v-model="search">
						</el-input>&nbsp;&nbsp;
					</div>
					<el-button style="margin:10px;" size="mini" type="primary" icon="document" @click="phoneSelect">查询
					</el-button>
					<el-button style="margin:10px;" size="mini" type="primary" icon="document" @click="cleans2">重置
					</el-button>&nbsp;&nbsp;
					<el-button style="margin: 10px 0;" :disabled="!isAuth('mission:add')" size="mini" type="primary"
						icon="document" @click="choiaddNotice()">添加信息</el-button>&nbsp;&nbsp;&nbsp;&nbsp;
					<el-button style="margin: 10px 0;"
						:disabled="!isAuth('mission:delete') || multipleSelection.length <= 0 " size="mini"
						type="danger" icon="document" @click="choideletes()">批量删除</el-button>
				</div>
				<div style="float: right;margin-right:2%;">

				</div>
				<el-table v-loading="tableDataLoading" :data="choicenData.records"
					@selection-change="handleSelectionChange">
					<el-table-column type="selection">
					</el-table-column>
					<el-table-column prop="id" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="nickName" label="发布人昵称">
						<template slot-scope="scope">
							　<span style="color: #4f9dec;cursor: pointer;" @click="updatesvideo(scope.row)"
								v-text="scope.row.nickName"></span>
						</template>
					</el-table-column>
					<el-table-column prop="titleImg" label="发布人头像">
						<template slot-scope="scope">
							　　<img v-if="scope.row.titleImg &&scope.row.titleImg!=''" :src="scope.row.titleImg"
								width="40" height="40" />
							<span v-else>暂无图片</span>
						</template>
					</el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人昵称" width = "180"></el-table-column>
					<el-table-column prop = "ordersNo" label = "接单人头像" width = "180"></el-table-column>
					<el-table-column prop="name" label="名称" width="150">
					</el-table-column>
					<el-table-column prop="house" label="任务类型" width="100">
					</el-table-column>
					<el-table-column prop="house" label="物品类型" width="100">
					</el-table-column>
					<el-table-column prop="area" label="物品价值" width="100">
					</el-table-column>
					<el-table-column prop="price" label="物品重量" width="100">
					</el-table-column>
					<el-table-column prop="area" label="跑腿费(元)" width="100">
					</el-table-column>
					<el-table-column prop="area" label="起始地址" width="100">
					</el-table-column>
					<el-table-column prop="area" label="结束地址" width="100">
					</el-table-column>
					<el-table-column prop="address" label="发单时间" width="200">
					</el-table-column>
					<el-table-column prop="address" label="备注" width="200">
					</el-table-column>
					<!-- <el-table-column prop="remark" label="详情" width="200">
						<template slot-scope="scope">
							　　<div
								style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;">
								{{scope.row.remark}}
							</div>
						</template>
					</el-table-column>
					<el-table-column prop="titleImg" label="详情图" width="180">
						<template slot-scope="scope">
							<div v-if="scope.row.img &&scope.row.img!=''">
								<img v-for="(item,index) in scope.row.imgs" :key="index" :src="item" width="40"
									height="40" style="margin-right: 10px;" @click="refund(scope.row)" />
							</div>
							<span v-else>暂无图片</span>
						</template>
					</el-table-column> -->
					<el-table-column prop="phone" label="是否保价" width="140">
					</el-table-column>
					<el-table-column prop="contactNum" label="是否专人直达" width="100">
					</el-table-column>
					<el-table-column prop="classifyName" label="红包" width="100">
					</el-table-column>
					<el-table-column prop="classifyName" label="小费" width="100">
					</el-table-column>
					<el-table-column prop="status" label="是否开启收货码" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;" v-if="scope.row.status === 0 ">待审核</span>
							<el-switch v-if="scope.row.status ==1 || scope.row.status ==2" v-model="scope.row.status"
								@change="change3(scope.row.state,scope.row)" :active-value="openValue"
								:inactive-value="closeValue" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
							<span style="color: #4f9dec;" v-if="scope.row.status === 3 ">驳回</span>
						</template>
					</el-table-column>
					<el-table-column prop="status" label="状态" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;" v-if="scope.row.status === 0 ">待审核</span>
							<el-switch v-if="scope.row.status ==1 || scope.row.status ==2" v-model="scope.row.status"
								@change="change3(scope.row.state,scope.row)" :active-value="openValue"
								:inactive-value="closeValue" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
							<span style="color: #4f9dec;" v-if="scope.row.status === 3 ">驳回</span>
						</template>
					</el-table-column>
					<el-table-column prop="createTime" label="创建时间" width="180">
					</el-table-column>
					<el-table-column label="操作" prop="id" width="240" fixed='right' align="center">
						<template slot-scope="scope">
							<el-button size="mini" type="primary" v-if="scope.row.status === 0 "
								@click="shenhe( scope.row)">审核</el-button>
							<el-button size="mini" type="primary" @click="choiCompile(scope.$index, scope.row)">修改
							</el-button>
							<el-button size="mini" type="danger" :disabled="!isAuth('mission:delete')"
								@click="choidelete(scope.row)">删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;float:right">
					<el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
						:page-sizes="[10, 20, 30, 40]" :page-size="size" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="choicenData.total">
					</el-pagination>
				</div>

			</el-tab-pane>

			<!--    图片展示-->
			<el-dialog title="图片" :visible.sync="dialogVisible" width="800px">
				<span v-if="imageUrl.length>0" v-for="(item, index) in imageUrl" :key="index" style="">
					<!-- <el-image style = "width: 100px; height: 100px" :src = "item" :preview-src-list="imageUrl"></el-image>-->
					<img :src="item" alt="" style="width: 45%; height: 100%;margin: 15px;display:inline-block;">
				</span>
				<span v-else>暂无图片</span>
			</el-dialog>
			<!-- 任务审核弹框 -->
			<el-dialog title="任务审核" :visible.sync="dialogFormVisible8" center>
				<el-radio-group v-model="radio" style="width: 100%;margin-bottom: 30px;margin-left: 200px;">
					<el-radio :label="1">通过</el-radio>
					<el-radio :label="2">驳回</el-radio>
				</el-radio-group>
				<div style="margin-bottom: 10px;">
					<span style="width: 200px;display: inline-block;text-align: right;">驳回理由：</span>
					<el-input style="width:50%;" v-model="contents" type="text" placeholder="请输入驳回理由"></el-input>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button @click="dialogFormVisible8 = false">取 消</el-button>
					<el-button type="primary" @click="refuseto()">确 定</el-button>
				</div>
			</el-dialog>
		</el-tabs>
	</div>
</template>

<script>
	import {
		quillEditor
	} from 'vue-quill-editor'
	import 'quill/dist/quill.core.css'
	import 'quill/dist/quill.snow.css'
	import 'quill/dist/quill.bubble.css'
	import quillConfig from '../locality/quill-config.js'
	import axios from 'axios';
	import {
		jsonp
	} from 'vue-jsonp'
	import {
		provinceAndCityData,
		regionData,
		provinceAndCityDataPlus,
		regionDataPlus,
		CodeToText,
		TextToCode
	} from 'element-china-area-data'
	var cityOptions = []
	var geocoder, map, markersArray = [];
	export default {
		components: {
			quillEditor
		},
		data() {
			return {
				dialogWidth: 0,
				size: 10,
				page: 1,
				state: '',
				limit: 10,
				classify: 6,
				classifys: 6,
				openValue: 1,
				closeValue: 2,
				title: '',
				type: '',
				nav: '',
				name: '',
				keyword: '',
				describes: '',
				checkBoxData: [], //多选框选择的值
				method: 'false',
				formLabelWidth: '200px',
				activeName: 'first',
				tableDataLoading: true,
				tableDataLoading4: false,
				dialogFormVisible3: false,
				dialogFormVisible1: false,
				dialogFormVisible2: false,
				dialogFormVisible5: false,
				dialogFormVisible6: false,
				dialogFormVisible7: false,
				dialogFormVisible8: false,
				dialogFormVisible9: false,
				homeData: [],
				homeData1: [
					{id: 0,title: '全部'},
					{title:'帮我送',id:1},
					{title:'帮我取',id:2},
				],
				choicenData2: [],
				choicenData: [],

				url: '',
				imageUrl: '',
				imageUrl2: '',
				id: '',
				bannerData: [],
				form1: {
					// id: '',
					// url: '',
					// imageUrl: ''
				},
				formcomp: {
					id: '',
					state: '',
					title: '',
					url: '',
					imageUrl: ''
				},
				userId: '',
				search: '',
				myPhone: '',
				classifyIds: 0,
				statusId: -1,
				statuss: [{
						id: -1,
						title: '全部'
					},
					{
						id: 0,
						title: '待审核'
					},
					{
						id: 1,
						title: '上架'
					},
					{
						id: 2,
						title: '下架'
					},
					{
						id: 3,
						title: '驳回'
					}
				],
				// 房屋信息
				phone: '', //电话
				name: '', //标题
				userIdss: '', //用户id
				titleImg: '', //封面图
				img: [], //详情图
				status: '', //状态0待审核  1上架  2下架 3驳回 (修改添加不传)
				classifyId: 4, //分类id
				area: '', //大小
				house: '', //户型
				price: '', //价格
				labels: [], //标签集合
				address: '', //地址
				latitude: '', //纬度
				longitude: '', //经度
				remark: '', //描述
				editorOption: {},
				options: regionData,
				storeAddress: [],
				storeAddre: '请选择城市',
				province: '', //省
				city: '', //市
				district: '', //区
				ids: '', //信息id

				nickName: '',
				userIds: {}, //用户列表
				bq: '', //输入的标签名
				missions: 0,
				shenheId: 0, //审核id
				contents: '', //驳回理由
				dialogVisible: false,
				radio: 1,
				multipleSelection: [],
				campus: '',
				campus1: '',
				campusName: '',
				homeData2: [
					{campusName:'全部',campusId:''},
					{campusName:'文件',campusId:1},
					{campusName:'餐饮',campusId:2},
					{campusName:'生鲜',campusId:3},
					{campusName:'蛋糕',campusId:4},
					{campusName:'鲜花',campusId:5},
					{campusName:'钥匙',campusId:6},
					{campusName:'数码',campusId:7},
					{campusName:'服装',campusId:8},
					{campusName:'快递',campusId:9},
					{campusName:'其他',campusId:10},
				],
				quillOption: quillConfig,
				statusIdd: 1
			}
		},
		methods: {
			//查看照片
			refund(e) {
				console.log(e)
				this.imageUrl = []
				if (e.img != null) {
					let img = e.img.split(',')
					if (img.length != 0) {
						this.imageUrl = img
					}
				}
				this.dialogVisible = true
			},
			// 多选
			changeFun(val) {
				this.checkBoxData = val
			},
			handleAvatarSuccess3(file) {
				this.formcomp.imageUrl = file.data
			},
			handleAvatarSuccess4(file) {
				this.imageUrl = file.data
			},
			handleSizeChange(val) {
				this.size = val
				this.bannerSelect()
			},
			handleCurrentChange(val) {
				this.page = val
				this.bannerSelect()
			},
			handleSizeChange1(val) {
				this.limit = val
				this.InformationSelect()
			},
			handleCurrentChange1(val) {
				this.page = val
				this.InformationSelect()
			},
			handleSizeChange2(val) {
				this.size = val
				this.tableDataLoading4 = true
				this.userClass()
			},
			handleCurrentChange2(val) {
				this.page = val
				this.tableDataLoading4 = true
				this.userClass()
			},
			handleClick(tab, event) {
				this.campus = ''
				this.campus1 = ''
				if (tab._props.label == '同城帮买') {
					this.nav = 1
					this.homeSelect()
				}
				if (tab._props.label == '同城服务') {
					this.type = 1
					this.bannerSelect()
				}
				if (tab._props.label == '送取任务') {
					this.type = 2
					this.InformationSelect()
				}
			},
			handleAvatarSuccess(file) {
				this.imageUrl = file.data
			},
			handleAvatarSuccess2(file2) {
				this.form1.imageUrl = file2.data
			},
			// 添加社区分类弹框
			addNavigation() {
				this.dialogFormVisible9 = true
			},
			// 添加社区分类
			NagNoticeTo() {
				if (this.title == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入标题',
						type: 'warning'
					})
					return
				}
				// if (this.url == '') {
				// 	this.$notify({
				// 		title: '提示',
				// 		duration: 1800,
				// 		message: '请输入路由',
				// 		type: 'warning'
				// 	})
				// 	return
				// }
				if (this.imageUrl == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请上传图片',
						type: 'warning'
					})
					return
				}
				this.$http({
					url: this.$http.adornUrl('activity/insertActivity'),
					method: 'post',
					data: this.$http.adornData({
						'state': this.state,
						'url': this.url,
						'title': this.title,
						'imageUrl': this.imageUrl,
						'status': this.statusIdd
					})
				}).then(({
					data
				}) => {
					this.dialogFormVisible9 = false
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.url = ''
							this.title = ''
							this.imageUrl = ''
							this.homeSelect()
						}
					})
				})
			},
			// 删除分类
			navdeletes(row) {
				if (row.id > 13) {
					this.$confirm(`确定删除此条信息?`, '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.$http({
							url: this.$http.adornUrl(`/activity/delete/${row.id}`),
							method: 'post',
							data: this.$http.adornData({})
						}).then(({
							data
						}) => {
							this.$message({
								message: '删除成功',
								type: 'success',
								duration: 1500,
								onClose: () => {
									this.homeSelect()
								}
							})
						})
					}).catch(() => {})
				} else {
					this.$message({
						message: '此条信息不可删除',
						type: 'warning',
						duration: 1500,
						onClose: () => {}
					})
				}

			},
			// 添加
			addNoticelun() {
				this.dialogFormVisible6 = true
			},
			//轮播数据
			bannerSelect() {
				this.$http({
					url: this.$http.adornUrl('banner/selectBannerList'),
					method: 'get',
					params: this.$http.adornParams({
						'state': this.state,
						'classify': this.classify,
					})
				}).then(({
					data
				}) => {
					let returnData = data.data
					this.bannerData = returnData
				})
			},
			// 添加轮播图
			addNoticeTo() {
				if (this.imageUrl == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请上传图片',
						type: 'warning'
					})
					return
				}
				if (this.name == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入名称',
						type: 'warning'
					})
					return
				}
				this.$http({
					url: this.$http.adornUrl('banner/insertBanner'),
					method: 'post',
					data: this.$http.adornData({
						'classify': this.classify,
						'imageUrl': this.imageUrl,
						'state': this.state,
						'url': this.url,
						'name': this.name,
						'describes': this.describes
					})
				}).then(({
					data
				}) => {
					this.dialogFormVisible6 = false
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.imageUrl = ''
							this.state = ''
							this.url = ''
							this.name = ''
							this.describes = ''
							this.bannerSelect()
						}
					})
				})
			},
			// 修改轮播图
			amendBanner(index, rows) {
				this.dialogFormVisible1 = true
				this.id = rows.id
				this.imageUrl = rows.imageUrl
				if (rows.url) {
					this.url = rows.url
				} else {
					this.url = ''
				}

				this.sort = rows.sort
				this.state = rows.state
				this.name = rows.name
				this.describes = rows.describes
			},
			// 确认修改轮播图你
			amendNoticeTo() {
				this.$http({
					url: this.$http.adornUrl(
						`banner/updateBannerById?id=${this.id}&imageUrl=${this.imageUrl}&url=${this.url}&state=${this.state}&sort=${this.sort}&name=${this.name}&describes=${this.describes}`
					),
					method: 'post',
					data: this.$http.adornData({})
				}).then(({
					data
				}) => {
					this.dialogFormVisible1 = false
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.bannerSelect()
						}
					})
				})
			},
			// 删除banner图
			deletes(row) {
				let delid = row.id
				this.$confirm(`确定删除此条信息?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http({
						url: this.$http.adornUrl(`banner/deleteBannerById?id=${delid}`),
						method: 'post',
						data: this.$http.adornData({})
					}).then(({
						data
					}) => {
						this.$message({
							message: '删除成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.bannerSelect()
							}
						})
					})
				}).catch(() => {})

			},
			// 修改弹框
			compile(index, rows) {
				this.dialogFormVisible2 = true
				this.formcomp.id = rows.id
				this.formcomp.state = rows.state
				this.formcomp.title = rows.title
				this.formcomp.url = rows.url
				this.formcomp.imageUrl = rows.imageUrl
				this.statusIdd = rows.status
			},
			// 修改商品类别
			compileNoticeTo() {
				if (this.formcomp.title == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入标题',
						type: 'warning'
					})
					return
				}
				// if (this.formcomp.url == '') {
				// 	this.$notify({
				// 		title: '提示',
				// 		duration: 1800,
				// 		message: '请输入路由',
				// 		type: 'warning'
				// 	})
				// 	return
				// }
				if (this.formcomp.type == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请上传图片',
						type: 'warning'
					})
					return
				}
				this.$http({
					url: this.$http.adornUrl(`/activity/updateActivity`),
					method: 'post',
					data: this.$http.adornData({
						'id': this.formcomp.id,
						'state': this.formcomp.state,
						'title': this.formcomp.title,
						'url': this.formcomp.url,
						'imageUrl': this.formcomp.imageUrl,
						'status': this.statusIdd
					})
				}).then(({
					data
				}) => {
					this.dialogFormVisible2 = false
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.homeSelect()
						}
					})
				})
			},

			//添加精选商品
			choiaddNotice() {
				this.campus = ''
				this.campus1 = ''
				this.dialogFormVisible5 = true
				this.getMyLocation()
			},

			// 搜索
			shousuo() {
				this.tableDataLoading = true
				this.$http({
					url: this.$http.adornUrl4(
						`/supersearch/apikey/maxd/back/100/sort/2/keyword/${this.keyword}/is_coupon/1/tb_p/1/min_id/1`
					),
					method: 'get',
					params: this.$http.adornParams({})
				}).then(({
					data
				}) => {
					console.log(data)
					if (data && data.code === 1) {
						this.tableDataLoading = false
						let returnData = data.data
						this.choicenData2 = returnData
					}
				})
			},
			// 查询
			phoneSelect() {
				this.page = 1
				this.InformationSelect()
			},
			// 重置
			cleans2() {
				this.status = -1
				this.classify = 0
				this.myPhone = ''
				this.search = ''
				this.page = 1
				this.campus = ''
				this.campus1 = ''
				console.log('this.phone', this.myPhone)
				this.InformationSelect()
			},
			// 获取社区数据列表
			homeSelect() {
				this.tableDataLoading = true
				this.$http({
					url: this.$http.adornUrl(`activity/selectActivity`),
					method: 'get',
					params: this.$http.adornParams({

					})
				}).then(({
					data
				}) => {
					this.tableDataLoading = false
					let returnData = data.data
					this.homeData1 = [{
						id: 0,
						title: '全部'
					}]
					if (data.data) {
						for (var i in data.data) {
							this.homeData1.push(data.data[i])
							data.data[i].state = Number(data.data[i].state)
						}
					}
					console.log(data.data.state)
					this.homeData = data.data
				})
			},
			// 信息数据
			InformationSelect() {
				this.userId = this.$store.state.user.id
				this.$http({
					url: this.$http.adornUrl(`information/selectInformationList`),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
						'search': this.search,
						'classify': this.classifyIds,
						'status': this.statusId,
						'phone': this.myPhone,
						'campus': this.campus1
					})
				}).then(({
					data
				}) => {
					this.tableDataLoading = false
					for (var i in data.data.records) {
						if (data.data.records[i].img) {
							data.data.records[i].imgs = data.data.records[i].img.split(',')
						}

					}
					let returnData = data.data
					this.choicenData = returnData


				})
			},
			// 封面图片上传
			handleAvatarSuccess5(file) {
				this.titleImg = file.data;
			},
			// 详情图片上传
			handleRemove(file) {
				console.log(file, this.img)
				this.img.push(file.data);
			},
			// 删除详情图
			dels(index) {
				this.img.splice(index, 1);
				console.log(this.img)
			},
			// 获取分类id
			onChang(e) {
				console.log(e)
				this.classifyId = e
			},
			// 获取社区
			onChang3(e) {
				console.log(e)
				this.campus1 = e
			},
			// 获取省市区
			handleChange55(value) {
				value = this.$refs['cascaderAddr'].currentLabels
				this.province = value[0]
				this.city = value[1]
				this.district = value[2]
				this.form.city = value[1]
				if (this.city == '市辖区') {
					this.city = this.province
				}
				if (this.form.city == '市辖区') {
					this.city = this.province
				}
				console.log(this.$refs['cascaderAddr'].currentLabels)
			},
			//定位获得当前位置信息
			getMyLocation() {
				var geolocation = new qq.maps.Geolocation("SZWBZ-QDWC3-M233R-YDXW5-TZT7Q-S4FJ7", "代驾管理管理");
				geolocation.getIpLocation(this.showPosition, this.showErr);
				// geolocation.getLocation(this.showPosition, this.showErr);//或者用getLocation精确度比较高
			},
			showPosition(position) {
				console.log(position);
				// this.latitude = position.lat;
				// this.longitude = position.lng;
				// this.city = position.city;
				this.setMap();
			},
			showErr(e) {
				console.log("定位失败", e);
				this.getMyLocation(); //定位失败再请求定位，测试使用
			},
			//位置信息在地图上展示
			setMap() {
				//步骤：定义map变量 调用 qq.maps.Map() 构造函数   获取地图显示容器
				//设置地图中心点
				var myLatlng = new qq.maps.LatLng(this.latitude, this.longitude);
				//定义工厂模式函数
				var myOptions = {
					zoom: 13, //设置地图缩放级别
					center: myLatlng, //设置中心点样式
					mapTypeId: qq.maps.MapTypeId.ROADMAP //设置地图样式详情参见MapType
				}
				// //获取dom元素添加地图信息
				var map = new qq.maps.Map(document.getElementById("container1"), myOptions);
				//给地图添加点击事件

				//给定位的位置添加图片标注
				var marker = new qq.maps.Marker({
					position: myLatlng,
					map: map
				});
				// `````````````
				var that = this;
				if (that.longitude == '') {
					var center = new qq.maps.LatLng(34.34281541842994, 108.93970884382725);
				} else {
					var center = new qq.maps.LatLng(that.latitude, that.longitude);
				}

				var map = new qq.maps.Map(document.getElementById("container1"), {
					center: center,
					zoom: 13
				});
				var marker = new qq.maps.Marker({
					position: center,
					map: map
				});
				var latlngBounds = new qq.maps.LatLngBounds();
				qq.maps.event.addListener(map, "click", function(event) {
					console.log(event, qq.maps);
					that.longitude = event.latLng.getLng(); // 经度
					that.latitude = event.latLng.getLat(); // 纬度
					jsonp('https://apis.map.qq.com/ws/geocoder/v1/?location=' + event.latLng.getLat() + ',' + event
						.latLng.getLng() + '&key=SZWBZ-QDWC3-M233R-YDXW5-TZT7Q-S4FJ7&get_poi=1&output=jsonp', {
							myCustomUrlParam: 'veryNice'
						}).then(response => {
						console.log('response', response)
						that.address = response.result.formatted_addresses.recommend

					}).catch(error => {
						// handle error
					}).then(() => {
						// always executed
					});
					if (markersArray) {
						for (let i in markersArray) {
							markersArray[i].setMap(null);
						}
					}
					var marker = new qq.maps.Marker({
						map: map,
						position: event.latLng
					});
					markersArray.push(marker);

				});
				geocoder = new qq.maps.Geocoder({
					complete: function(result) {
						console.log(result);
						that.longitude = result.detail.location.lng;
						that.latitude = result.detail.location.lat;
						map.setCenter(result.detail.location);
						var marker = new qq.maps.Marker({
							map: map,
							position: result.detail.location
						});
						markersArray.push(marker);
					}
				});
			},
			// 地图定位
			select() {
				console.log(this.address, this.address.replace(/^\s+|\s+$/gm, ''))

				if (this.address == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入详细地址',
						type: 'warning'
					});
					return
				} else {
					var add = this.province + this.city + this.district + this.address
					let that = this
					jsonp('https://apis.map.qq.com/ws/geocoder/v1/?address==' + add +
						'&key=SZWBZ-QDWC3-M233R-YDXW5-TZT7Q-S4FJ7&get_poi=1&output=jsonp', {
							myCustomUrlParam: 'veryNice'
						}).then(response => {
						// handle success
						if (response.message == '查询无结果') {
							this.$notify({
								title: '提示',
								duration: 1800,
								message: '详细地址输入有误，请重新输入',
								type: 'warning'
							});
							return
						}
						console.log('response', response)
						that.longitude = response.result.location.lng; // 经度
						that.latitude = response.result.location.lat; // 纬度
						// that.address = response.result.address_components.province + response.result.address_components
						// 	.city + response.result.address_components.district + response.result.title
						that.setMap()
					}).catch(error => {
						// handle error
					}).then(() => {
						// always executed
					});
				}

			},
			// 获取用户列表弹框
			userselect() {
				this.dialogFormVisible3 = true
				this.tableDataLoading4 = true
				this.userClass()
			},
			// 获取用户列表
			userClass() {
				let phone = -1
				if (this.phone) {
					phone = this.phone
				}
				let nickName = -1
				if (this.nickName) {
					nickName = this.nickName
				}
				this.$http({
					url: this.$http.adornUrl('user/selectUserList'),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
						'member': this.member,
						'phone': this.phone
					})
				}).then(({
					data
				}) => {
					this.tableDataLoading4 = false
					let returnData = data.data
					this.userIds = returnData
				})
			},
			// 查询用户列表
			userclick() {
				this.page = 1
				this.tableDataLoading4 = true
				this.userClass()
			},
			// 重置用户列表数据
			userclose() {
				this.phone = ''
				this.nickName = ''
				this.tableDataLoading4 = true

				this.userClass()
			},
			// 确定用户
			confirm(row) {
				this.userIdss = row.userId
				this.nickName = row.nickName
				this.phone = row.phone
				if (this.nickName == '' || this.nickName == null) {
					this.nickName = row.phone
				}
				this.dialogFormVisible3 = false
			},
			// 添加标签
			btnTj() {
				if (this.bq == '' || this.bq == ' ') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入标签名',
						type: 'warning'
					});
					return
				} else {
					console.log('this.bq', this.bq)
					this.labels.push(this.bq)
					this.bq = ''
				}

			},
			// 删除标签
			dels1(index) {
				this.labels.splice(index, 1);
				console.log(this.labels)
			},
			// 确定添加
			addmissionNoticeTo() {
				console.log(this.userIdss)
				if (this.name == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入标题',
						type: 'warning'
					});
					return
				}
				if (this.titleImg == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请上传任务封面图',
						type: 'warning'
					});
					return
				}
				// var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
				if (this.phone == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入联系电话',
						type: 'warning'
					});
					return
				}
				// if (this.address == '') {
				// 	this.$notify({
				// 		title: '提示',
				// 		duration: 1800,
				// 		message: '请输入地址详情',
				// 		type: 'warning'
				// 	});
				// 	return
				// }
				// toString()
				if (this.longitude == '') {
					this.select()
					return
				}
				let urls = ''
				if (this.missions == 0) {
					urls = 'information/insertInformation'
				} else {
					urls = 'information/updateInformation'
				}
				let that = this
				setTimeout(function() {
					that.$http({
						url: that.$http.adornUrl(urls),
						method: 'post',
						data: that.$http.adornData({
							'name': that.name,
							'label': that.labels.toString(),
							'address': that.address,
							'phone': that.phone,
							'titleImg': that.titleImg,
							'img': that.img.toString(),
							'classifyId': that.classifyId,
							'latitude': that.latitude,
							'longitude': that.longitude,
							'remark': that.remark,
							'area': that.area,
							'house': that.house,
							'price': that.price,
							'province': that.province,
							'userId': that.userIdss,
							'id': that.ids,
							'campus': that.campus
						})
					}).then(({
						data
					}) => {
						console.log('提交结果', data)
						if (data.code == 0) {
							that.$message({
								message: '操作成功',
								type: 'success',
								duration: 1500,
								onClose: () => {
									that.prev()
									that.campus = ''
									// that.name = ''
									// that.labels = []
									// that.address = ''
									// that.phone = ''
									// that.titleImg = ''
									// that.img = []
									// that.classifyId = ''
									// that.latitude = ''
									// that.longitude = ''
									// that.remark = ''
									// that.area = ''
									// that.house = ''
									// that.price = ''
									// that.province = ''
									// that.userIdss = ''
									// that.ids = ''
									that.InformationSelect()
								}
							})
						} else {
							this.$notify({
								title: '提示',
								duration: 1800,
								message: data.msg,
								type: 'warning'
							});
						}


					})
				}, 1000)
			},
			// 关闭添加信息弹框
			prev() {
				this.dialogFormVisible5 = false
				this.campus = ''
				this.name = ''
				this.labels = []
				this.address = ''
				this.phone = ''
				this.titleImg = ''
				this.img = []
				this.classifyId = ''
				this.latitude = ''
				this.longitude = ''
				this.remark = ''
				this.area = ''
				this.house = ''
				this.price = ''
				this.province = ''
				this.userIdss = ''
				this.ids = ''
			},
			// 审核
			shenhe(row) {
				this.shenheId = row.id
				this.dialogFormVisible8 = true
			},
			// 提交审核
			refuseto(row) {
				if (this.radio == 2 && this.contents == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入驳回理由',
						type: 'warning'
					})
					return
				} else {
					let ids = this.shenheId
					let status = this.radio
					let content = this.contents
					this.$http({
						url: this.$http.adornUrl(
							`information/auditInformation?ids=${ids}&status=${status}&content=${content}`),
						method: 'post',
						data: this.$http.adornData({})
					}).then(({
						data
					}) => {
						this.dialogFormVisible8 = false
						this.$message({
							message: '审核完成',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.radio = 1
								this.contents = ''
								this.InformationSelect()
							}
						})
					})
				}
			},
			// 修改信息弹框
			choiCompile(index, row) {
				console.log(index, row)
				this.labels = []
				this.missions = 1
				if (this.missions == 1) {
					if (row.label) {
						this.labels = row.label.split(',');
					}
					this.address = row.address;
					this.name = row.name;
					this.phone = row.phone;
					this.titleImg = row.titleImg;
					if (row.img) {
						this.img = row.img.split(',');
					}
					this.classifyId = row.classifyId;
					this.latitude = row.latitude;
					this.longitude = row.longitude;
					this.remark = row.remark;
					this.area = row.area;
					this.house = row.house;
					this.price = row.price;
					this.province = row.province;
					this.userId = row.userId;
					this.url = row.url;
					this.ids = row.id;
					this.campus = row.campus;
					this.campusName = row.campusName
				}
				this.dialogFormVisible5 = true
				this.getMyLocation()
			},
			// 删除信息
			choidelete(row) {
				let delid = row.id
				this.$confirm(`确定删除此条信息?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http({
						url: this.$http.adornUrl(`information/deleteInformationById?ids=${delid}`),
						method: 'post',
						params: this.$http.adornData({})
					}).then(({
						data
					}) => {
						this.$message({
							message: '删除成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.InformationSelect()
							}
						})
					})
				}).catch(() => {})
			},
			// 筛选信息
			animeDat2(state) {
				this.InformationSelect()
			},
			animeDat3(state) {
				this.InformationSelect()
			},
			// 多选
			handleSelectionChange(val) {

				var arr = []
				for (var i in val) {
					arr.push(val[i].id)
				}
				this.multipleSelection = arr;
				console.log('val', val, this.multipleSelection)
			},
			// 批量删除
			choideletes() {
				console.log(this.multipleSelection)
				let delid = this.multipleSelection.toString()
				this.$confirm(`确定删除信息?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http({
						url: this.$http.adornUrl(`information/deleteInformationById?ids=${delid}`),
						method: 'post',
						params: this.$http.adornData({})
					}).then(({
						data
					}) => {
						this.$message({
							message: '删除成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.InformationSelect()
							}
						})
					})
				}).catch(() => {})
			},
			// 获取社区数据列表
			homeSelect1() {
				this.tableDataLoading = true
				this.$http({
					url: this.$http.adornUrl('helpCampus/selectCampusList'),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
						'content': this.content
					})
				}).then(({
					data
				}) => {
					this.tableDataLoading = false
					let returnData = data.data;
					this.homeData2 = returnData
				})
			},
			// 分类是否启用
			change2(val, row) {
				this.$http({
					url: this.$http.adornUrl(`activity/updateActivityStatus?id=${row.id}`),
					method: 'post',
					data: this.$http.adornData({})
				}).then(({
					data
				}) => {
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.homeSelect()
						}
					})
				})
			},
			// 社区轮播图是否启用
			change(val, row) {
				this.$http({
					url: this.$http.adornUrl(`banner/updateBannerStateById?id=${row.id}`),
					method: 'post',
					data: this.$http.adornData({})
				}).then(({
					data
				}) => {
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.homeSelect1()
						}
					})
				})
			},
			// 任务上下架
			change3(val, row) {
				this.$http({
					url: this.$http.adornUrl(`information/updateInformationStatus?id=${row.id}`),
					method: 'post',
					data: this.$http.adornData({})
				}).then(({
					data
				}) => {
					this.$message({
						message: '操作成功',
						type: 'success',
						duration: 1500,
						onClose: () => {
							this.homeSelect()
						}
					})
				})
			},
			// 详情跳转
			updatesvideo(row) {
				// this.$http({
				//   url: this.$http.adornUrl('/common/type/91'),
				//   method: 'get',
				//   params: this.$http.adornParams({})
				// }).then(({
				//   data
				// }) => {
				//   let returnData = data.data
				//   this.value = returnData.value
				//   if (this.value == 1) {
				this.$router.push({
					path: '/userDetail',
					query: {
						userId: row.userId
					}
				})
				//   } else {
				//     this.$router.push({
				//       path: '/userDetailThree',
				//       query: {
				//         userId: row.userId
				//       }
				//     })
				//   }
				// })
			},
		},
		mounted() {
			this.homeSelect1()
			this.homeSelect()
		}
	}
</script>

<style>
	.customWidth {
		width: 80% !important;
	}

	.adver_main.box {
		display: block;
		max-width: 100%;
		text-align: center;
		border: 1px dotted rgba(67, 79, 103, .4);
	}

	.cards {
		padding: 0 8px;
		margin-bottom: 15px;
	}

	.adver_main.box a {
		display: flex;
		justify-content: center;
		height: 150px;
		line-height: 150px;
		text-decoration: none
	}

	.bannerManin {
		border: 1px solid #e8e8e8;
		font-size: 14px;
		padding: 0 24px;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 113px;
		color: rgba(0, 0, 0, .65);
	}

	.bannerManin span {
		display: inline-block;
		margin-left: 5px;
	}

	.bannerManin img {
		width: 48px;
		height: 48px;
		border-radius: 50%;
	}

	.bannerbtn {
		display: flex;
		border-top: none !important;
		border: 1px solid #e8e8e8;
		padding: 11px;
		font-size: 14px;
		color: #3E8EF7;
	}

	.bannerbtn a {
		flex: 1;
		text-align: center;
		color: #3E8EF7 !important;
		text-decoration: none;
	}

	.imgs {
		position: relative;
		border-radius: 6px;
		width: 148px;
		height: 148px;
		margin-right: 10px;
		display: inline-block;
	}

	.dels {
		position: absolute;
		top: 0;
		left: 0;
		display: none;
	}

	.dels .el-icon-delete {
		line-height: 148px;
		padding-left: 58px;
		font-size: 25px;
		color: #fff;
	}

	.imgs:hover .dels {
		width: 100%;
		height: 100%;
		background: #000;
		display: block;
		opacity: 0.5;
	}

	.bqList {
		padding: 4px 14px;
		margin: 4px;
		border: 1px solid #efefef;
		font-size: 12px;
		color: #999;
		border-radius: 4px;
		margin-right: 15px;
	}

	.delss {
		display: none;
		position: relative;
	}

	.delss .el-icon-delete {
		position: absolute;
		top: 0;
	}

	.bqList:hover .delss {
		display: initial;
		opacity: 0.5;

	}

	.tj {
		padding: 6px !important;
		margin: 4px;
		font-size: 12px;
		border: 1px solid #ccc;
		border-radius: 4px;
	}
</style>
